// 1.引入公用样式表
require("../../assets/css/index.less");
require("../../assets/fonts/iconfont.css");
// 2.引入当前样式表
require("./sportsClass.less");
// 3.引入公用js模块
let dom = require("../../utils/dom.js");
let https = require("../../utils/https.js");
let local = require("../../utils/local.js");

// 4.具体功能
dom.ready(function () {
  //获取所有课程列表
  function getCourseList() {
    https.get("/api/train/courseList", function (res) {
      //判定
      if (res.errno == 0) {
        res.data.map((v) => {
          console.log(v);
          if (v.courseId == 1) {
            //最新课程
            dom.getEle("#newCourseList").innerHTML += `
                        <li>
                            <a href="datelis.html?id=${v.courseId}">
                                <img src="${https.BASE_URL + v.imgurl}" alt="">
                                <div class="p5">
                                    <h2 class="f14">${v.name}</h2>
                                    <p>${v.desc}</p>
                                </div>
                            </a>
                        </li>`;
          } else {
            //课程
            // console.log('课程', v);
            dom.getEle("#courseList").innerHTML += `
                        <li>
                            <a>
                                <img data-box="${v.courseId}" src="${
              https.BASE_URL + v.imgurl
            }" alt="">
                                <div class="p5">
                                    <h2 class="f14">${v.name}</h2>
                                    <p>${v.desc}</p>
                                </div>
                            </a>
                        </li>`;
          }
        });
      }
    });
  }


  dom.createFoot(1)
  getCourseList();
});
